pkgname=firmware-samsung-klimt
pkgver=3.0
pkgrel=0
pkgdesc="Firmware for Samsung klimtwifi and klimtlte"
url="https://github.com/exynos5420/android_vendor_samsung_klimt-common"
arch="armv7"
license="proprietary"
options="!check !strip !archcheck !spdx !tracedeps pmb:cross-native"
subpackages="
	$pkgname-downstream:downstream
	$pkgname-mainline:mainline
"

_klimt_commit="418be0d7638e9b67c0fc3e6a3403951bf64ba67f"
_klimt_url="$url/raw/$_klimt_commit"
_klimt_wifi_files="
	bcmdhd_apsta.bin
	bcmdhd_ibss.bin
	bcmdhd_mfg.bin
	bcmdhd_sta.bin
	cred.conf
	nvram_mfg.txt
	nvram_net.txt
"

for _i in $_klimt_wifi_files; do
	source="$source $pkgname-$_klimt_commit-$_i::$_klimt_url/proprietary/etc/wifi/$_i";
done

package() {
	mkdir -p "$pkgdir"
}

downstream() {
	pkgdesc="Firmware for Samsung klimt* when using downstream kernel"
	depends="firmware-samsung-exynos5420-downstream"
	mkdir -p "$subpkgdir"

	local file
	for file in $_klimt_wifi_files; do
		 install -Dm644 "$srcdir/$pkgname-$_klimt_commit-$file" \
			"$subpkgdir/lib/firmware/postmarketos/$file"
	done
}

mainline() {
	pkgdesc="Firmware for Samsung klimt* when using mainline kernel"
	depends="linux-firmware-s5p-mfc linux-firmware-brcm"
	mkdir -p "$subpkgdir"

	install -Dm644 "$srcdir/$pkgname-$_klimt_commit"-nvram_net.txt \
		"$subpkgdir"/lib/firmware/brcm/brcmfmac4354-sdio.samsung,klimt-wifi.txt
	ln -s brcmfmac4354-sdio.samsung,klimt-wifi.txt \
		"$subpkgdir"/lib/firmware/brcm/brcmfmac4354-sdio.samsung,klimt-lte.txt
}

sha512sums="
4449d14eafe81afe2b3a8f81b00af1fd36e493cfde8892d83a9853b9ee9fc8551970b363f7e73d4a98640a043856e1374deabea5ec06dc46e86312d6e3687d35  firmware-samsung-klimt-418be0d7638e9b67c0fc3e6a3403951bf64ba67f-bcmdhd_apsta.bin
755810fc6a72860a21a3392c6fa1070382877e6c1bccea353dd808e5ed2c1741d5c67481465252857b1f86bb1928cf4d9014e6e88063d156afeb7d278149c202  firmware-samsung-klimt-418be0d7638e9b67c0fc3e6a3403951bf64ba67f-bcmdhd_ibss.bin
712d9fa7b823383fcd586419dbd54eb824bf23cab17d352a39032d304ff0768cc29f47d2fcd0a9c819e18c55f688b32984f9514e775358f6299caacefa5e668f  firmware-samsung-klimt-418be0d7638e9b67c0fc3e6a3403951bf64ba67f-bcmdhd_mfg.bin
e382700c6af5f592ebb10c4eca038289ae09a3de36a3f330b81c2c6322b75a85d1bbe1e3061f4c2d889bf32e9cf92f17e3474c324e166aa89847bd401aa902df  firmware-samsung-klimt-418be0d7638e9b67c0fc3e6a3403951bf64ba67f-bcmdhd_sta.bin
16ee43800bf7c05f550a14036ef1d648999568996854c72c1ef3965a8fd18eabfda284266fa2e2a0fee8c5fec01fd9a7e22b11b6723797742b5a6260e0b44096  firmware-samsung-klimt-418be0d7638e9b67c0fc3e6a3403951bf64ba67f-cred.conf
be114ae215e223d06fccab5773a887c9cda19e44246e852a32be1c7c3d19ccece30f227d167bdb92da1011a925cf82775a6755b162935f893303398231a81d1a  firmware-samsung-klimt-418be0d7638e9b67c0fc3e6a3403951bf64ba67f-nvram_mfg.txt
e543dc853cfbda057b30476c5e28e6f04a16682dfb6c01a70d0c960d3acd17e0b3d365a03bd1b644c708a36a7c46afafb4218af81af4023b34e82d572aad3807  firmware-samsung-klimt-418be0d7638e9b67c0fc3e6a3403951bf64ba67f-nvram_net.txt
"
